<?php
/**
 *
 * Created by www.soe-soe.com
 * Author: shijy
 * Date: 2016/7/7
 * Time: 11:19
 */

namespace Common\Model\OtherSystem;


use Think\Exception;

class NoticeOtherSystem
{
    const STATUS_SUCCESS=0;
    const STATUS_FAILURE_SYSTEM=1;
    const STATUS_FAILURE_FEEDBACK=2;
    public function notice($actionName,$param){
        if(IS_CLI){
            return $this->notice_cli($actionName,$param);
        }else{
            return $this->notice_cgi($actionName,$param);
        }

        throw new Exception('未定义');
    }
    public function mkSign($timestamp,$param){
        throw new Exception('未定义');
    }

    /**
     * 增加他系统接口调用失败日志
     * Author: shijy
     * @param $systemName 系统名
     * @param $interface 接口
     * @param $param  参数
     * @param $result 结果
     * @return mixed false表示添加日志失败
     */
    public  function addNoticeOtherSystemLog($systemName,&$interface,&$param,$result,$resultStatus){
        return M('broadcast_log',null,DB_MAIN_CFG)->add(
            array(
                'otherSystem'=>$systemName,
                'interface'=>$interface,
                'paramStr'=>is_array($param)?json_encode($param):$param,
                'resultStr'=>is_array($result)?json_encode($result):$result,
                'addTime'=>time(),
                'resultStatus'=>$resultStatus
            )
        );
    }
}